layout.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { routing } from "@/i18n/routing";
  2. import clsx from "clsx";
  3. import { Metadata, Viewport } from "next";
  4. import { NextIntlClientProvider } from "next-intl";
  5. import { getMessages } from "next-intl/server";
  6. import { Inter as FontSans } from "next/font/google";
  7. import { notFound } from "next/navigation";
  8. import { ReactNode } from "react";
  9. import "../globals.scss";
  10. import { Providers } from "./providers";
  11. import { server } from "@/utils/server";
  12. import { ConfigType } from "@/api/config";
  13. // 加载字体
  14. const fontSans = FontSans({
  15. subsets: ["latin"],
  16. variable: "--font-sans",
  17. });
  18. export const viewport: Viewport = {};
  19. export const metadata: Metadata = {
  20. title: {
  21. template: "%s | BCWin777",
  22. default: "BCWin777",
  23. },
  24. keywords: ["BCWin777"],
  25. description: "The home of over 30 million players",
  26. appleWebApp: {
  27. statusBarStyle: "black",
  28. },
  29. formatDetection: {
  30. email: false,
  31. address: false,
  32. telephone: false,
  33. },
  34. referrer: "no-referrer",
  35. other: {
  36. viewport: [
  37. "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0," +
  38. " viewport-fit=cover ",
  39. ],
  40. },
  41. };
  42. interface Og {
  43. description: string;
  44. keywords: string;
  45. title: string;
  46. url: string;
  47. address: string
  48. }
  49. interface System extends ConfigType {
  50. og: Og
  51. }
  52. const getSystemReq = () => {
  53. return server.request<System>({
  54. url: '/v1/api/front/system/configs',
  55. method: 'POST'
  56. })
  57. }
  58. export default async function LocaleLayout({
  59. children,
  60. params: { locale },
  61. }: {
  62. children: ReactNode;
  63. params: { locale: string };
  64. }) {
  65. if (!routing.locales.includes(locale as any)) {
  66. notFound();
  67. }
  68. const messages = await getMessages();
  69. const { data } = await getSystemReq()
  70. // console.log(data)
  71. return (
  72. <html lang={locale} suppressHydrationWarning>
  73. <head>
  74. {/* <!-- SEO Metadata --> */}
  75. {/* <meta name="description" content="{{ .Description }}" />
  76. <meta name="keywords" content="{{ .Keywords }}" />
  77. <meta name="author" content="Besoft" />
  78. <meta name="viewport" content="width=device-width, initial-scale=1.0" /> */}
  79. {/* <!-- Open Graph Metadata --> */}
  80. <meta property="og:title" content={data?.og?.title || ''} />
  81. <meta property="og:description" content={data?.og?.description || ''} />
  82. <meta property="og:image" content={data?.og?.url || ''} />
  83. <meta property="og:url" content={data?.og?.address || ''} />
  84. <meta property="og:type" content="website" />
  85. {/* <!-- Twitter Card Metadata --> */}
  86. <meta name="twitter:card" content={data?.og?.address || ''} />
  87. <meta name="twitter:title" content={data?.og?.title || ''} />
  88. <meta name="twitter:description" content={data?.og?.description || ''} />
  89. <meta name="twitter:image" content={data?.og?.url || ''} />
  90. </head>
  91. <body className={clsx("font-sans", fontSans.variable)}>
  92. <NextIntlClientProvider messages={messages}>
  93. <Providers themeProps={{ attribute: "class" }}>{children}</Providers>
  94. </NextIntlClientProvider>
  95. </body>
  96. </html>
  97. );
  98. }